#!/usr/bin/python3
# -*- coding:utf-8 -*-
# @Time   :2021/12/13
# @Author :CJX
# @File   :sql_insert_err.py

import pymysql
import time


def sql_insert_err(err_name):
    con = pymysql.connect(
        host='127.0.0.1',
        port=3306,
        user='root',
        password='!qAz2WsX3edc',
        db='ph',
        charset='utf8'
    )
    cur = con.cursor()
    address = "TEST001"
    time1 = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))
    cur.executemany("INSERT err_msg(address,time,err_name) VALUE(%s,%s,%s)", [(address, time1, err_name)])
    con.commit()
    cur.close()
    return


def sql_insert_suc(suc_name):
    con = pymysql.connect(
        host='127.0.0.1',
        port=3306,
        user='root',
        password='!qAz2WsX3edc',
        db='ph',
        charset='utf8'
    )
    cur = con.cursor()
    address = "TEST001"
    time1 = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))
    cur.executemany("INSERT suc_msg(address,time,suc_name) VALUE(%s,%s,%s)", [(address, time1, suc_name)])
    con.commit()
    cur.close()
    return
